package com.sskj.finance.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.finance.bean.HomeQbwAccountList;
import com.sskj.finance.http.HttpConfig;
import com.sskj.finance.ui.activity.TransferActivity;
import com.sskj.lib.http.JsonCallBack;


public class TransferActivityPresenter extends BasePresenter<TransferActivity> {


    /**
     * 交易、理财账户划转
     *
     * @param type 1交易账户to理财账户 2理财账户to交易账户
     * @param num  充值数量
     * @param tpwd 资金密码
     * @param code 币种标识，如：BTC、ETH
     * @return
     */
    public void transfer(String type, String num, String tpwd, String code) {
        httpService.transfer(type, num, tpwd, code).execute(new JsonCallBack<HttpData>() {
            @Override
            public void onSuccess(Response<HttpData> response) {
                HttpData httpData = response.body();
                if (httpData.getStatus() == HttpConfig.OK) {
                    mView.transferSuccess();
                }
            }
        });
    }

    /**
     * 交易、理财账户币种列表
     *
     * @return
     */
    public void homeQbwAccountList() {
        httpService.homeQbwAccountList().execute(new JsonCallBack<HttpData<HomeQbwAccountList>>() {
            @Override
            public void onSuccess(Response<HttpData<HomeQbwAccountList>> response) {
                HttpData<HomeQbwAccountList> httpData = response.body();
                if (httpData.getStatus() == HttpConfig.OK) {
                    mView.updateCoin(httpData.getData());
                }
            }
        });
    }
}
